/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package myhibernatetest;
import org.hibernate.*;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
 *
 * @author Arnav
 */

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Configuration config= new Configuration().configure();
        SessionFactory factory= config.buildSessionFactory();

        Session session= factory.openSession();

        try
        {
            Train train= (Train)session.get(Train.class, 1001);
            System.out.println("The Train Name: "+train.getTrainName());
            System.out.println("Source: "+train.getSource());
            System.out.println("Destination: "+train.getDestination());
            System.out.println("Availability: "+train.getSeatAvailable());
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        finally
        {
            session.close();
        }
    }

}
